<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ movie.title }} - 电影推荐助手</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <div class="container">
        <header>
            <h1>电影推荐助手</h1>
            <p>发现您可能喜欢的电影</p>
        </header>
        
        <nav>
            <ul>
                <li><a href="{{ url_for('index') }}">首页</a></li>
                <li><a href="{{ url_for('movies') }}">电影列表</a></li>
                <li><a href="{{ url_for('recommendations') }}">为您推荐</a></li>
            </ul>
        </nav>
        
        <section class="movie-detail-section">
            <div class="movie-header">
                <h2>{{ movie.title }}</h2>
                <div class="movie-meta">
                    <span class="movie-year">{{ movie.year }}</span>
                    <span class="movie-genre">{{ movie.genre }}</span>
                </div>
            </div>
            
            <div class="movie-content">
                <div class="movie-info">
                    <p class="movie-director"><strong>导演：</strong>{{ movie.director }}</p>
                    <p class="movie-description"><strong>剧情简介：</strong>{{ movie.description }}</p>
                    <p class="movie-rating"><strong>平均评分：</strong>
                        <span class="rating-stars">
                            {% for i in range(5) %}
                            {% if i < avg_rating %}
                            ★
                            {% else %}
                            ☆
                            {% endif %}
                            {% endfor %}
                        </span>
                        <span class="rating-score">{{ avg_rating }}</span>
                    </p>
                </div>
                
                <div class="rating-section">
                    <h3>您的评分</h3>
                    <form action="{{ url_for('rate_movie') }}" method="post">
                        <input type="hidden" name="movie_id" value="{{ movie.id }}">
                        <div class="rating-input">
                            <label>
                                <input type="radio" name="rating" value="1" {% if user_rating and user_rating[0] == 1 %}checked{% endif %}>
                                1星
                            </label>
                            <label>
                                <input type="radio" name="rating" value="2" {% if user_rating and user_rating[0] == 2 %}checked{% endif %}>
                                2星
                            </label>
                            <label>
                                <input type="radio" name="rating" value="3" {% if user_rating and user_rating[0] == 3 %}checked{% endif %}>
                                3星
                            </label>
                            <label>
                                <input type="radio" name="rating" value="4" {% if user_rating and user_rating[0] == 4 %}checked{% endif %}>
                                4星
                            </label>
                            <label>
                                <input type="radio" name="rating" value="5" {% if user_rating and user_rating[0] == 5 %}checked{% endif %}>
                                5星
                            </label>
                        </div>
                        <button type="submit">提交评分</button>
                    </form>
                    {% if user_rating %}
                    <p class="rating-hint">您已对此电影评分，重新选择后点击提交可更新评分。</p>
                    {% else %}
                    <p class="rating-hint">为电影评分后，系统会根据您的喜好提供更好的推荐。</p>
                    {% endif %}
                </div>
            </div>
            
            <div class="action-buttons">
                <a href="{{ url_for('movies') }}" class="back-btn">返回电影列表</a>
                <a href="{{ url_for('recommendations') }}" class="recommend-btn">查看为您推荐的电影</a>
            </div>
        </section>
        
        <footer>
            <p>© 2025 电影推荐助手 - 为电影爱好者打造的简单推荐系统</p>
        </footer>
    </div>
</body>
</html>